import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig(additionalKeys)
import System.IO

import XMonad.Prompt
import XMonad.Prompt.Man
import XMonad.Prompt.RunOrRaise

import XMonad.Layout.ShowWName
import XMonad.Layout.ResizableTile -- ResizableTall 1 (3/4) (1/2) []||| 
import XMonad.Layout.Roledex
import XMonad.Layout.Circle
-- import XMonad.Layout.MagicFocus --magicFocus
import XMonad.Layout.NoBorders --noBorders Full
import XMonad.Layout.PerWorkspace

import XMonad.Actions.SwapWorkspaces


myWorkspaces = "Control":"Web":"Edit":"Entertainment" :"BBS":"System":"Lord":"Wheel":"Back&Downloading":[]

myLayoutDefault = ResizableTall 1 (3/100) (1/2) [] |||layoutHook defaultConfig
myLayoutFull = noBorders Full ||| myLayoutDefault
myLayoutWheels = Circle
myLayoutTerms = Roledex ||| layoutHook defaultConfig

myLayout =     onWorkspace "Control" myLayoutTerms
               $ onWorkspace "Wheel" myLayoutWheels
               $ onWorkspace "Lord" myLayoutFull
               $ onWorkspace "Entertainment" myLayoutFull
               $ myLayoutDefault

myManageHook = composeAll
               [ className =? "XClock" --> doFloat
                 ]
-- myLayout = layoutHook defaultConfig

main = do
  xmonad $ defaultConfig {
         manageHook = manageDocks 
                      <+> myManageHook 
                      <+>  manageHook defaultConfig
             ,workspaces = myWorkspaces
             ,layoutHook = showWName (avoidStruts  $ myLayout )
             ,modMask = mod3Mask
             ,terminal = "xfterm4"
             } `additionalKeys` (
       [((mod3Mask,xK_f), spawn "firefox")
       ,((mod3Mask,xK_d), spawn "emacs")
       ,((mod3Mask,xK_b), spawn "benliud")
       ,((mod3Mask,xK_s), spawn "smplayer") 
       ,((mod3Mask,xK_0), spawn "/home/huand/bin/dtimer")
       ,((mod3Mask,xK_o), spawn "thunar") 
       ,((mod3Mask .|. shiftMask, xK_m), manPrompt defaultXPConfig)
       ,((mod3Mask , xK_x), runOrRaisePrompt defaultXPConfig)
       ,((mod3Mask, xK_a), sendMessage MirrorShrink)
       ,((mod3Mask, xK_z), sendMessage MirrorExpand)
       ]++
       [((mod3Mask .|. controlMask, k), windows $ swapWithCurrent i)
            | (i, k) <- zip myWorkspaces [xK_1 ..]])

